from django.db import models

# Create your models here.
class User(models.Model):
    id = models.AutoField(primary_key=True)
    username = models.CharField(max_length=8,verbose_name="账号")
    pwd = models.CharField(max_length=8,verbose_name="密码")
    name = models.CharField(max_length=20,verbose_name="姓名")
    tel = models.CharField(max_length=11,verbose_name="电话号码")


class Company(models.Model):
    id = models.AutoField(primary_key=True)
    username = models.CharField(max_length=8,verbose_name="账号")
    pwd = models.CharField(max_length=8,verbose_name="密码")
    name = models.CharField(max_length=30,verbose_name="公司名称")
    caddress = models.CharField(max_length=100,verbose_name="公司地址")
    users2 = models.ManyToManyField(to=User)

class Job(models.Model):
    title = models.CharField(max_length=200,verbose_name="标题")
    location = models.CharField(max_length=100,verbose_name="工作地点")
    description = models.TextField(verbose_name="职位描述")
    pay = models.CharField(max_length=20,verbose_name="薪资")
    experience = models.CharField(max_length=20,verbose_name="经验")
    type = models.CharField(max_length=10,verbose_name="工作类型")
    requirements = models.TextField(verbose_name="学历要求")
    posted_date = models.DateTimeField(auto_now_add=True,verbose_name="发布日期")
    num = models.IntegerField(verbose_name="招聘人数")
    endtime = models.DateTimeField(auto_now_add=False,verbose_name="招聘截至日期")
    name = models.CharField(max_length=50,verbose_name="单位名称")
    company = models.ForeignKey('Company', on_delete=models.CASCADE)
    users = models.ManyToManyField(to=User,through='Interview')

class Resume(models.Model):
    id = models.AutoField(primary_key=True)
    age = models.IntegerField(verbose_name="年龄")
    address = models.CharField(max_length=60, verbose_name="居住地")
    Professional = models.CharField(max_length=20, verbose_name="专业名")
    company_name1 = models.CharField(max_length=50,verbose_name="公司名称",null=True)
    company_name2 = models.CharField(max_length=50,verbose_name="公司名称",null=True)
    company_name3 = models.CharField(max_length=50,verbose_name="公司名称",null=True)
    datetime1 = models.CharField(max_length=100,verbose_name="工作时间",null=True)
    datetime2 = models.CharField(max_length=100,verbose_name="工作时间",null=True)
    datetime3 = models.CharField(max_length=100,verbose_name="工作时间",null=True)
    content1 = models.CharField(max_length=255,verbose_name="工作介绍",null=True)
    content2 = models.CharField(max_length=255,verbose_name="工作介绍",null=True)
    content3 = models.CharField(max_length=255,verbose_name="工作介绍",null=True)
    col_name = models.CharField(max_length=50,verbose_name="大学名称",null=True)
    col_time = models.CharField(max_length=100,verbose_name="大学时间",null=True)
    col_content = models.CharField(max_length=255,verbose_name="大学说明",null=True)
    max_deu = models.CharField(max_length=20,verbose_name="最高学历",null=True)
    speciality = models.TextField(max_length=255,verbose_name="特长",null=True)
    category = models.ForeignKey('User',on_delete=models.CASCADE)
    file = models.FileField(upload_to='documents/',verbose_name="用户简历")


class Interview(models.Model):
    user = models.ForeignKey('User', on_delete=models.CASCADE)
    job = models.ForeignKey('Job', on_delete=models.CASCADE)
    state_user = models.BooleanField(verbose_name="用户接受情况，1同意，0不同意",null=True)
    state_company = models.BooleanField(verbose_name="公司接受情况，1同意，0不同意",null=True)
    order_time = models.CharField(verbose_name="面试时间",max_length=100,null=True)
    order_place = models.CharField(verbose_name="面试地点",max_length=255,null=True)
    enroll = models.BooleanField(verbose_name="最终情况，1录取，0拒绝录用",null=True)

